package com.jiyun.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.jiyun.mapper.StudentMapper;
import com.jiyun.pojo.Room;
import com.jiyun.pojo.Student;
import com.jiyun.service.StudentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class StudentServiceImpl implements StudentService {
    @Autowired
    private StudentMapper studentMapper;

    @Override
    public List<Student> findList(Student student) {
        return studentMapper.findList(null);
    }

    @Override
    public PageInfo<Student> findList2(Integer pageNum, Integer pageSize, Student student) {
        PageHelper.startPage(pageNum,pageSize);
        List<Student> list = studentMapper.findList(student);
        PageInfo<Student> pageInfo = new PageInfo<>(list);
        return pageInfo;
    }

    @Override
    public List<Room> findRoomList() {
        return studentMapper.findRoomList();
    }

    @Override
    public void add(Student student) {
        studentMapper.add(student);
    }

    @Override
    public Student findById(Integer sid) {
      return  studentMapper.findById(sid);
    }

    @Override
    public void update(Student student) {
        studentMapper.update(student);
    }
}
